<template>
  <div>
    <!--搜索查询-->
    <el-row>
      <!-- <el-col :span="">&nbsp;</el-col> -->
      <el-col :span="4"
        ><el-input
          v-model="title"
          size="mini"
          clearable
          placeholder="请输入模板标题"
        ></el-input
      ></el-col>
      <!--v-has="'dictData:search'"-->
      <el-col :span="2"
        ><el-button
          type="primary"
          size="mini"
          @click="search()"
          icon="el-icon-search"

          >搜索</el-button
        ></el-col
      >
      <!--v-has="'dictData:flush'"-->
      <el-col :span="2"
        ><el-button
          type="primary"
          size="mini"
          @click="flush()"
          icon="el-icon-refresh"
          >刷新</el-button
        ></el-col
      >
    </el-row>
    <el-row>
      <el-table :data="tableData" style="width: 100%">
        <el-table-column
          prop="title"
          label="模块标题"
          align="center"
          width="80"
        >
        </el-table-column>
        <el-table-column
          prop="businessType"
          label="业务类型"
          :formatter="typeFormat"
          align="center"
          width="80"
        >
        </el-table-column>
        <el-table-column
          prop="method"
          label="方法名称"
          align="center"
          width="180"
        >
        </el-table-column>
        <el-table-column
          prop="operatorType"
          :formatter="type"                            
          label="操作类别"
          align="center"
          width="80"
        >
        </el-table-column>
        <el-table-column
          prop="operName" 
          width="80"
          label="操作人员"
        >
        </el-table-column>
        <el-table-column
          prop="deptName" 
          width="80"
          label="部门名称"
        >
        </el-table-column>
        <el-table-column
          prop="operUrl" 
          width="120"
          label="请求地址"
        >
        </el-table-column>
        <el-table-column
          prop="operIp" 
          width="80"
          label="请求IP"
        >
        </el-table-column>
        <el-table-column
          prop="operLocation" 
          width="80"
          label="操作地址"
        >
        </el-table-column>
        <el-table-column
          prop="operParam" 
          width="150"
          label="请求参数"
        >
        </el-table-column>
        <el-table-column
          prop="status" 
          width="80"
          :formatter="status"
          label="状态"
        >
        </el-table-column>
        <el-table-column
          prop="errorMsg" 
          width="80"
          label="错误信息"
        >
        </el-table-column>
        <el-table-column
          prop="operTime" 
          width="150"
          label="操作时间"
        >
        </el-table-column>

      </el-table>
    </el-row>
    <el-row>
      <!--分页插件-->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[2, 3, 5, 10, 20]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </el-row>

  </div>
</template>

<script>
export default {
  data() {
    return {
      condition:"",
      data: [], //权限树数组对象
      tableData: [],
      currentPage: 1, //页码 第几页
      pageSize: 5, //每页显示数量
      total: 100, //总条数
      title: '', //搜索form表单
      form: {}, //form表单对象
    };
  },
  created() {
    //初始化方法 类似于jquery $({})
    this.loadData();
  },
  //所有函数
  methods: {
    //加载数据
    loadData(){
      this.$http.post("/system/api/operLog/findAll?currentPage="+this.currentPage+"&pageSize="+this.pageSize+"&title="+this.title).then(resp=>{
        this.tableData=resp.data.data.list;
        this.total=resp.data.data.total;
      })
    },
   
    //处理每页数量发生变化
    handleSizeChange(val) {
      //console.log(`每页 ${val} 条`);
      //让每页数量发生变化
      this.pageSize = val;
      //重载数据
      this.loadData();
    },
    //处理当前页变化
    handleCurrentChange(val) {
      //console.log(`当前页: ${val}`);
      //让每页数量发生变化
      this.currentPage = val;
      //重载数据
      this.loadData();
    },
    //查询
    search() {
      this.loadData();
    },
    //刷新
    flush() {
      location.reload();
    },
    //格式化性别方法
    typeFormat(row, column, cellValue, index) {
      //row当前行数据
      //column 列名称
      //cellValue 列的值
      //index 下标
      //alert(cellValue);
      return cellValue == 0 ? "其他" : cellValue == 1 ? "新增" : cellValue == 2 ? "修改":"删除";
      /**  if(cellValue==0){
                    return '男';
                }else if(cellValue==1){
                    return '女';
                }
                return '未知';
               */
    },
    //格式化性别方法
    type(row, column, cellValue, index) {
      //row当前行数据
      //column 列名称
      //cellValue 列的值
      //index 下标
      //alert(cellValue);
      return cellValue == 0 ? "其他" : cellValue == 1 ? "后台用户" : "手机端用户";
      /**  if(cellValue==0){
                    return '男';
                }else if(cellValue==1){
                    return '女';
                }
                return '未知';
               */
    },
    //格式化方法
    status(row, column, cellValue, index) {
      return cellValue == 0 ? "正常" : "异常";
     
    },

  },
};
</script>